import { PureComponent } from 'react';

function logRanderTime(OriginComponent) {
  return class extends PureComponent {
    UNSAFE_componentWillMount() {
      this.beginTime = Date.now();
    }

    componentDidMount() {
      const endTime = Date.now();
      console.log(`组件${OriginComponent.name}渲染时间：${endTime - this.beginTime}ms`);
    }

    render() {
      return <OriginComponent {...this.props} />;
    }
  }
}

export default logRanderTime;